package com.lianzheng.dao.impl;

import java.util.List;
import java.util.Map;
import java.util.HashMap;

import com.lianzheng.dao.TbSysUserinfoDAO;
import com.lianzheng.model.TbSysUserinfo;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.orm.ObjectRetrievalFailureException;
import org.springframework.stereotype.Repository;


/**
 * This class interacts with Spring's IbatisTemplate to save/delete
 * <p>
 * <a href="TbSysUserinfo.DAOimpl.java.html"><i>View Source</i></a>
 * </p>
 *
 * @author <a href="mailto:heymanchen@gmail.com">haihua chen</a>
*/
@Repository
public class TbSysUserinfoDAOimpl extends SqlMapClientDaoSupport implements TbSysUserinfoDAO {

    /**
     * @see com.lianzheng.dao.TbSysUserinfoDAO#getTbSysUserinfo($keytype)
     */

    public TbSysUserinfo getTbSysUserinfo(String userid){
        return (TbSysUserinfo)getSqlMapClientTemplate().queryForObject("getTbSysUserinfo", userid);
    }

    public TbSysUserinfo getTbSysUserinfoFull(String userid){
        return (TbSysUserinfo)getSqlMapClientTemplate().queryForObject("getTbSysUserinfoFull", userid);
    }

    public void addTbSysUserinfo(final TbSysUserinfo tbSysUserinfo) {
        getSqlMapClientTemplate().update("addTbSysUserinfo", tbSysUserinfo);
    }

    public void updateTbSysUserinfo(final TbSysUserinfo tbSysUserinfo) {
    getSqlMapClientTemplate().update("updateTbSysUserinfo", tbSysUserinfo);
    }

    public void removeTbSysUserinfo(String userid){
        getSqlMapClientTemplate().update("removeTbSysUserinfo", userid);
    }

    public List getTbSysUserinfos() {
        return getSqlMapClientTemplate().queryForList("getTbSysUserinfos",null);
    }

    public List getTbSysUserinfoByAnd(final TbSysUserinfo tbSysUserinfo,String order_by){
        Map map = new HashMap();
        map.put(FIND_BY_AND, "True");
        if (order_by != null)
            map.put(ORDER_BY,order_by);
        tbSysUserinfo.setMagic(map);
        return getSqlMapClientTemplate().queryForList("getTbSysUserinfoByMap", tbSysUserinfo);
    }

    public List getTbSysUserinfoByOr(final TbSysUserinfo tbSysUserinfo,String order_by){
        Map map = new HashMap();
        map.put(FIND_BY_OR, "True");
        if (order_by != null)
            map.put(ORDER_BY,order_by);
        tbSysUserinfo.setMagic(map);
        return getSqlMapClientTemplate().queryForList("getTbSysUserinfoByMap", tbSysUserinfo);
    }
    
    public List getTbSysUserinfoByLike(final TbSysUserinfo tbSysUserinfo,String order_by){
        Map map = new HashMap();
        map.put(FIND_BY_LIKE, "True");
        if (order_by != null)
            map.put(ORDER_BY,order_by);
        tbSysUserinfo.setMagic(map);
        return getSqlMapClientTemplate().queryForList("getTbSysUserinfoByMap", tbSysUserinfo);
    }
}